/**
 * 本地存储模块
 */
export const getItem = (name) => {
    const data = window.localStorage.getItem(name)
    // data可能不是json格式字符串
    try {
        return JSON.parse(data)
    } catch (e) {
        //不是json格式直接返回
        return data
    }
}
export const setItem = (name, value) => {
    //如果value是对象，就把他转化为json格式字符串再存储
    if (typeof value === 'object') {
        value = JSON.stringify(value)
    }
    window.localStorage.setItem(name, value)
}
export const removeItem = (name) => {
    window.localStorage.removeItem(name)
}